package com.anyou.mall.goo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.anyou.mall.goo.domain.GooCouponShop;
import com.anyou.mall.goo.service.IGooCouponShopService;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.common.core.page.TableDataInfo;

/**
 * 优惠券与汽配商关联Controller
 *
 * @author ruoyi
 * @date 2022-05-06
 */
@Api(tags = "优惠券与汽配商关联")
@RestController
@RequestMapping("/goo/couponshop")
public class GooCouponShopController extends BaseController
{
    @Autowired
    private IGooCouponShopService gooCouponShopService;

    /**
     * 查询优惠券与汽配商关联列表
     */
    @ApiOperation("查询优惠券与汽配商关联列表")
    @PreAuthorize("@ss.hasPermi('goo:couponshop:list')")
    @GetMapping("/list")
    public TableDataInfo<List<GooCouponShop>> list(GooCouponShop gooCouponShop)
    {
        startPage();
        List<GooCouponShop> list = gooCouponShopService.selectGooCouponShopList(gooCouponShop);
        return getDataTable(list);
    }

    /**
     * 导出优惠券与汽配商关联列表
     */
    @ApiOperation("导出优惠券与汽配商关联列表")
    @PreAuthorize("@ss.hasPermi('goo:couponshop:export')")
    @Log(title = "优惠券与汽配商关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GooCouponShop gooCouponShop)
    {
        List<GooCouponShop> list = gooCouponShopService.selectGooCouponShopList(gooCouponShop);
        ExcelUtil<GooCouponShop> util = new ExcelUtil<GooCouponShop>(GooCouponShop.class);
        util.exportExcel(response, list, "优惠券与汽配商关联数据");
    }

    /**
     * 获取优惠券与汽配商关联详细信息
     */
    @ApiOperation("获取优惠券与汽配商关联详细信息")
    @PreAuthorize("@ss.hasPermi('goo:couponshop:query')")
    @GetMapping(value = "/{id}")
    public ApiResult<GooCouponShop> getInfo(@PathVariable("id") Long id)
    {
        return ApiResult.success(gooCouponShopService.selectGooCouponShopById(id));
    }

    /**
     * 新增优惠券与汽配商关联
     */
    @ApiOperation("新增优惠券与汽配商关联")
    @PreAuthorize("@ss.hasPermi('goo:couponshop:add')")
    @Log(title = "优惠券与汽配商关联", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult add(@RequestBody GooCouponShop gooCouponShop)
    {
        return ApiResult.success(gooCouponShopService.insertGooCouponShop(gooCouponShop));
    }

    /**
     * 修改优惠券与汽配商关联
     */
    @ApiOperation("修改优惠券与汽配商关联")
    @PreAuthorize("@ss.hasPermi('goo:couponshop:edit')")
    @Log(title = "优惠券与汽配商关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult edit(@RequestBody GooCouponShop gooCouponShop)
    {
        return ApiResult.success(gooCouponShopService.updateGooCouponShop(gooCouponShop));
    }

    /**
     * 删除优惠券与汽配商关联
     */
    @ApiOperation("删除优惠券与汽配商关联")
    @PreAuthorize("@ss.hasPermi('goo:couponshop:remove')")
    @Log(title = "优惠券与汽配商关联", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public ApiResult remove(@PathVariable Long[] ids)
    {
        return ApiResult.success(gooCouponShopService.deleteGooCouponShopByIds(ids));
    }
}
